﻿<UserControl x:Class="GiveAQuiz.Questions.MultipleChoiceQuestionEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             d:DesignHeight="161"
             d:DesignWidth="400">

  <Grid x:Name="LayoutRoot"
        VerticalAlignment="Top">
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"
                     MinHeight="61" />
      <RowDefinition />
    </Grid.RowDefinitions>
    <TextBox TextWrapping="Wrap"
             Text="{Binding QuestionText, Mode=TwoWay, NotifyOnValidationError=True}"
             Margin="0 4"
             MinHeight="45"
             d:LayoutOverrides="Height" />
    <Grid Margin="24 8"
          Grid.Row="2"
          VerticalAlignment="Top">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition />
      </Grid.RowDefinitions>
      <TextBlock Text="Choices:"
                 FontWeight="Bold" />
      <Button Style="{StaticResource ImageButton}"
              HorizontalAlignment="Right"
              VerticalAlignment="Top"
              ToolTipService.ToolTip="Add New Choice"
              Command="{Binding AddChoiceCommand}">
        <Image Source="/GiveAQuiz.Common;component/images/plus.png"
               Stretch="None" />
      </Button>

      <ItemsControl HorizontalAlignment="Stretch"
                    x:Name="theList"
                    Grid.Row="1"
                    HorizontalContentAlignment="Stretch"
                    ItemsSource="{Binding Choices}">
        <ItemsControl.ItemTemplate>
          <DataTemplate>
            <Grid d:DesignWidth="307"
                  d:DesignHeight="59"
                  Margin="0 2"
                  HorizontalAlignment="Stretch"
                  MinHeight="60">
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"
                                  MinWidth="28" />
                <ColumnDefinition />
                <ColumnDefinition Width="Auto"
                                  MinWidth="18" />
              </Grid.ColumnDefinitions>
              <RadioButton Content=""
                           IsChecked="{Binding IsCorrectChoice, Mode=TwoWay, NotifyOnValidationError=True}"
                           Checked="RadioButton_Checked"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center" />
              <TextBox TextWrapping="Wrap"
                       Text="{Binding ChoiceText, Mode=TwoWay, NotifyOnValidationError=True}"
                       d:LayoutOverrides="Width, Height"
                       HorizontalAlignment="Stretch"
                       Grid.Column="1"
                       AcceptsReturn="True"
                       MinHeight="30" />
              <StackPanel Grid.Column="2"
                          HorizontalAlignment="Right"
                          Width="18">
                <Button Style="{StaticResource ImageButton}"
                        Margin="1"
                        ToolTipService.ToolTip="Move Choice Up"
                        Command="{Binding DataContext.MoveUpChoiceCommand, ElementName=theList}"
                        CommandParameter="{Binding}">
                  <Image Source="/GiveAQuiz.Common;component/images/prev.png" />
                </Button>
                <Button Style="{StaticResource ImageButton}"
                        Margin="1"
                        ToolTipService.ToolTip="Move Choice Down"
                        Command="{Binding DataContext.MoveDownChoiceCommand, ElementName=theList}"
                        CommandParameter="{Binding}">
                  <Image Source="/GiveAQuiz.Common;component/images/next.png" />
                </Button>
                <Button Style="{StaticResource ImageButton}"
                        Margin="1"
                        ToolTipService.ToolTip="Delete Choice"
                        Command="{Binding DataContext.DeleteChoiceCommand, ElementName=theList}"
                        CommandParameter="{Binding}">
                  <Image Source="/GiveAQuiz.Common;component/images/del.png" />
                </Button>
              </StackPanel>
            </Grid>
          </DataTemplate>
        </ItemsControl.ItemTemplate>
      </ItemsControl>
    </Grid>

  </Grid>
</UserControl>
